# function Interpolate(X,Y, Xinterp) # Returns Yinterp[1…J] at Xinterp[1…J] which agrees with X[1…N], Y[1…N].
#
# function Zero(f, xLeft,xRight) # Returns x between Left,Right such that f(x)=0.
#
# function Minimize(f, x, xLeft,xRight) # Returns minimum value of f(x).
#
#
# This text file explains and gives examples of
# some of the routines in the file All Library Routines, which
# should be Opened before trying any of these examples.
#
#################
########
# Here are the xCOD's that are used.
xINTERPOLATE
# xCOD xINTERPOLATE(N:num; X,Y,dy2,w2:RealArray; Ni:num; Xi,Y, Err:num), interpolates y[1…N] of x[1…n] to the points Xi[1…ni]. dy2[1…N],w2[1…N] are work arrays. Output is Yi[1…Ni]. Err: 0=> no error, -1=> two x[j] are identical; an external program.
xZERO
# xCOD xZERO( prog F(n:num; xy:array); x,xLeft,xRight, tolerance, Err:num), Finds a zero of y(x), where F(2, [x,y]) calculates y. Input:guess for x,ragne xLeft,xRight, tolerance for x. Output:x. Err: -1=> x not in Left,Right range.; an external program.
xMINIMIZE
# xCOD xMINIMIZE( prog F(n:num; xy:array); x ,xL,xR, tol, err:num), finds min of y(x), where F(2, [x,y]) does y(x). In: guess for x, xL<x<xR, y(x) < y(xL) or y(xR), tolerance. Out: x. Err:-1=> x not >xL,<xR; -2=> f(x) > f(xL or xR); an external program.
#############
# Here are the interface routines.
# Given arrays y,x such that
# 1) x is ordered, and
# 2) y=f(x) for some function f, then
# Interpolate returns the points Yinterp = f(Xinterp) for
# an array (or single number) Xinterp.
# (Which need not be the same size as x or y.)
#
# The first work array, w1, actually returns the
# 2nd derivatives of y(x), which are used in this cubic
# spline interpolation.
#
function Interpolate(X,Y, Xinterp) # Returns Yinterp[1…J] at Xinterp[1…J] which agrees with X[1…N], Y[1…N].
. var n, w1,w2, Yinterp, err
. # Input:
. # x[1…n] ordered array
. # y[1…n] array, y=f(x)
. # Xinterp[1…J] co-ordinates to interpolate f(x) at.